// pages/searchcoupon/searchcoupon.js
import {
  ajax,
  src,
  util
} from "../../utils/util.js";
Page({

  /**
   * 页面的初始数据
   */
  data: {
    shoplist:'',
  },
  getlist:function(e) {
    console.log(e)
    var val = e.detail.value
    console.log(val)
    ajax('/api/CouponCollection/Get?requestContent=' + JSON.stringify({
      token: wx.getStorageSync('Access_token'),
      Vtype: 0,
      ActivityIDStr: '',
      PageIndex: 0,
      ProvinceName: wx.getStorageSync('address_component').province,
      CityName: wx.getStorageSync('address_component').city,
      DistrictName: wx.getStorageSync('address_component').district,
      Title: val
    }), {
        header: {
          'Accept': 'application/x-www-form-urlencoded', // 默认值
        },
        method: "get",
      }, res => {
        // console.log(res)
        this.setData({
          shoplist: res.Models
        })
      })
  },
  // 立即使用跳转
  tiaozhuan: function (e) {
    console.log(e)
    var pid = e.currentTarget.dataset.pid
    var vid = e.currentTarget.dataset.vid
    var id = e.currentTarget.dataset.id
    if (vid == 0) {
      wx.navigateTo({
        url: '/pages/index/index',
      })
    } else if (vid == 3) {  //商品详情  传id
      wx.navigateTo({
        url: '/pages/supermarket-details/details?goodsid=' + pid,
      })
    } else if (vid == 1) { //拼购详情 传id
      wx.navigateTo({
        url: '/pages/group-purchase-commodity/commodity?goodsid=' + pid,
      })
    } else if (vid == 2) { //跳转商户 传商户id  PublisherID
      wx.navigateTo({
        url: '/pages/today-shopping/shopping?id=' + id,
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarColor({
      frontColor: '#ffffff',
      backgroundColor: '#000',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})